KM.GUI = function()
{
    // dat.gui.js
    this.datGUI = null;
    
    // Ambient light parameters
    this.ambientLightParameters =
    {
        color: { r: 1, g: 1, b: 1 }
    };
    
    // Directional light parameters
    this.directionalLightParameters =
    {
        direction: { x: 0, y: 0, z: -1.0 },
        color: { r: 1, g: 1, b: 1 }
    };
};

KM.GUI.LOG = true;

KM.GUI.prototype = {
    constructor: KM.GUI,
    
    init: function()
    {
        // TODO : En attendant d'avoir une archi type MVC
        
        
        // dat.gui.js
        this.datGUI = new dat.GUI();
        
        // Ambient light
        var ambientLightFolder = this.datGUI.addFolder('Ambient light');
        var ambientLightColorR = ambientLightFolder.add( this.ambientLightParameters.color, 'r' ).min( 0 ).max( 1 ).step( 0.1 );
        ambientLightColorR.onChange( function( value ) {
            ambientLight._color._r = value;
        } );
        var ambientLightColorG = ambientLightFolder.add( this.ambientLightParameters.color, 'g' ).min( 0 ).max( 1 ).step( 0.1 );
        ambientLightColorG.onChange( function( value ) {
            ambientLight._color._g = value;
        } );
        var ambientLightColorB = ambientLightFolder.add( this.ambientLightParameters.color, 'b' ).min( 0 ).max( 1 ).step( 0.1 );
        ambientLightColorB.onChange( function( value ) {
            ambientLight._color._b = value;
        } );
        
        // Directional light
        var directionalLightFolder = this.datGUI.addFolder('Directional light');
        // Directional light direction
        var directionalLightX = directionalLightFolder.add( this.directionalLightParameters.direction, "x" );
        directionalLightX.onChange( function( value ) {
            directionalLight._direction[ 0 ] = value;
            vec3.normalize( directionalLight._direction, directionalLight._direction );
            vec3.scale( directionalLight._direction, -1 );
        } );
	var directionalLightY = directionalLightFolder.add( this.directionalLightParameters.direction, 'y' );
        directionalLightY.onChange( function( value ) {
            directionalLight._direction[ 1 ] = value;
            vec3.normalize( directionalLight._direction, directionalLight._direction );
            vec3.scale( directionalLight._direction, -1 );
        } );
	var directionalLightZ = directionalLightFolder.add( this.directionalLightParameters.direction, 'z' );
        directionalLightZ.onChange( function( value ) {
            directionalLight._direction[ 2 ] = value;
            vec3.normalize( directionalLight._direction );
            vec3.scale( directionalLight._direction, -1 );
        } );
        // Directional light color
        var directionalColorR = directionalLightFolder.add( this.directionalLightParameters.color, 'r' ).min( 0 ).max( 1 ).step( 0.1 );
        directionalColorR.onChange( function( value ) {
            directionalLight._color._r = value;
        } );
        var directionalColorR = directionalLightFolder.add( this.directionalLightParameters.color, 'g' ).min( 0 ).max( 1 ).step( 0.1 );
        directionalColorR.onChange( function( value ) {
            directionalLight._color._g = value;
        } );
        var directionalColorR = directionalLightFolder.add( this.directionalLightParameters.color, 'b' ).min( 0 ).max( 1 ).step( 0.1 );
        directionalColorR.onChange( function( value ) {
            directionalLight._color._b = value;
        } );
        
        directionalLightFolder.open();
    }
};